<template>
	<view class="page" :style="{'min-height':h+'px','padding-top':mt+'px'}">
		<c-nav-bar title="发票详情"></c-nav-bar>
		<view class="box status">
			<span style="color: #88919D;" v-if="item.status==1">已开票</span>
			<span style="color: #FEB000;" v-else>未开票</span>
		</view>
		<view class="box invoice">
			<view class="item">
				<view class="left">发票类型</view>
				<view class="right">{{item.type==1?'个人/非企业单位':'企业'}}</view>
			</view>
			<view class="item">
				<view class="left">发票抬头</view>
				<view class="right">{{item.invoiceTitle||''}}</view>
			</view>
			<view class="item">
				<view class="left">发票金额</view>
				<view class="right">{{item.invoicePrice||''}}元</view>
			</view>
			<view class="item">
				<view class="left">申请时间</view>
				<view class="right">{{item.createDate||''}}</view>
			</view>
			<view class="expand" @click="unfoldPackUp" v-if="!unfold&&item.type!=1">
				<text>展开更多信息</text>
				<image src="https://i.ringzle.com/file/20240726/6ab375bd6ac14ea4b67a7a39ef2dbe79.png"></image>
			</view>
			<template v-if="unfold&&item.type!=1">
				<view class="item">
					<view class="left">税号</view>
					<view class="right">{{item.taxNumber||''}}</view>
				</view>
				<view class="item">
					<view class="left">开户银行</view>
					<view class="right">{{item.depositBank||''}}</view>
				</view>
				<view class="item">
					<view class="left">开户行账号</view>
					<view class="right">{{item.bankAccount||''}}</view>
				</view>
				<view class="item">
					<view class="left">公司地址</view>
					<view class="right">{{item.unitAddress||''}}</view>
				</view>
				<view class="item">
					<view class="left">公司电话</view>
					<view class="right">{{item.unitPhone||''}}</view>
				</view>
			</template>
			<view class="expand" @click="unfoldPackUp" v-if="unfold&&item.type!=1">
				<text>收起</text>
				<image class="sq" src="https://i.ringzle.com/file/20240726/6ab375bd6ac14ea4b67a7a39ef2dbe79.png"></image>
			</view>
		</view>
		<view class="box order" @tap="toDetail">
			<view class="title">发票关联订单</view>
			<view class="review">
				<text>查看</text>
				<image src="@/static/index/steamerTicket/icon_yjt.png"></image>
			</view>
		</view>
		<view class="box info">
			<view class="title">接收信息</view>
			<view class="item" style="margin-top: 64rpx;">
				<view class="left">电子邮件</view>
				<view class="right">{{item.email||''}}</view>
			</view>
			<view class="item">
				<view class="left">手机号</view>
				<view class="right">{{item.guestPhone||''}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				h: uni.getSystemInfoSync().windowHeight,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				item:null,
				unfold:false
			}
		},
		onLoad(option) {
			if(option.id){
				this.getDetail(option.id)
			}
		},
		methods: {
			getDetail(id){
				this.$api.get(`/api/isinvoice/${id}`).then(res=>{
					if(res.data.code===0){
						this.item = res.data.data;
					}else this.$showModal(res.data.msg);
				})
			},
			unfoldPackUp(){
				this.unfold = !this.unfold;
			},
			toDetail(){
				if(!this.item.orderCode) return this.$showToast('暂无关联订单');
				uni.navigateTo({
					url: '/pagesMy/FishJialeList/FishJialeDetails?id=' + this.item.orderCode
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		background: #F5F8FA;
		box-sizing: border-box;
		padding-bottom: 20rpx;
		
		.box{
			width: 100%;
			padding: 38rpx 30rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			margin-top: 12rpx;
		}
		
		.status{
			span{
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 32rpx;
				line-height: 28rpx;
			}
		}
		
		.item{
			display: flex;
			margin-top: 48rpx;
			&:first-child{
				margin-top: 0;
			}
			.left{
				width: 184rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #999999;
				line-height: 32rpx;
				text-align: left;
			}
			.right{
				width: calc(100% - 184rpx);
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #333333;
				line-height: 32rpx;
				text-align: left;
			}
		}
		
		.invoice{
			.expand{
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 48rpx;
				text{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					line-height: 33rpx;
				}
				image{
					width: 28rpx;
					height: 28rpx;
					margin-left: 8rpx;
					&.sq{
						transform: rotate(180deg);
					}
				}
			}
		}
	
		.title{
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 32rpx;
			color: #333333;
			line-height: 32rpx;
		}
		
		.order{
			display: flex;
			align-items: center;
			justify-content: space-between;
			.review{
				display: flex;
				align-items: center;
				text{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					line-height: 33rpx;
				}
				image{
					width: 26rpx;
					height: 26rpx;
					margin-left: 10rpx;
				}
			}
		}
	}
</style>